<?php
require_once 'anet_php_sdk/AuthorizeNet.php'; // The SDK
$transaction = new AuthorizeNetAIM('8vUj8vA6M','856cBtJ3X6RGCk4N');
$transaction->setSandbox(true);
$transaction->setFields(
		        array(
			        'type' => 'AUTH_CAPTURE',
			        'amount' =>  '5.5',
			        'card_num' => '6011000000000012',
			        'exp_date' => '04/17',
			        'card_code' => '782',
			        'description' => 'From user : ' + 'tuan' + ' at site BaTam.Com' ,
			        'first_name' => 'John',
			        'last_name' => 'Doe',
			        'address' => '123 Main Street',
			        'city' => 'Boston',
			        'state' => 'MA'  ,
			        'zip' => '02142',
		        	'cust_id' => 1 ,
			        'customer_ip' => '127.0.0.1' , // sua sau
			        'invoice_num' => 1,
		        )
		    );

		    $response = $transaction->authorizeAndCapture();
		    if ($response->approved) {
					echo 'ok';
		      
		    } else {
		    		echo 'no ok';
		    		//return $response->response_reason_text;
		        echo 'Location: error_page.php?response_reason_code='.$response->response_reason_code.'&response_code='.$response->response_code.'&response_reason_text=' .$response->response_reason_text;
		    		//return 'error='.$response->error.'&response_reason_code='.$response->response_reason_code.'&response_code='.$response->response_code.'&response_reason_text=' .$response->response_reason_text;
		    }
?>